package JSON_Temp_Test;

import com.alibaba.fastjson.JSON;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class MapTest extends Mapper<LongWritable, Text, Temp, NullWritable> {
    Temp temp = new Temp();
    Temp k = new Temp();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        temp = JSON.parseObject(value.toString(), Temp.class);
        k.set(temp.getId(),temp.getDate(),temp.getTemp());
        context.write(k, NullWritable.get());
    }
}
